<?php 

class App_View_Helper_Messenger extends Zend_View_Helper_Abstract {
	
	const NS_INFORMATION 	= 'information'; 	// informacja
	const NS_ATTENTION 		= 'attention'; 		// uwaga
	const NS_SUCCESS 		= 'success'; 		// sukces
	const NS_ERROR 			= 'error'; 			// błąd
	
	public function messenger() {
		$fm = new Zend_Controller_Action_Helper_FlashMessenger();
		
		$tmp = array();
		
		foreach ( $this->getNs() as $ns) {
			$fm -> setNamespace($ns);
			if ($fm->hasMessages()) {
				foreach ($fm->getMessages() as $msg) {
					$tmp[$ns][] = $msg;
				}
			}	
		}
		return $tmp;
	}
	
	public function getNs() {
		return array(self::NS_INFORMATION, self::NS_ATTENTION, self::NS_SUCCESS, self::NS_ERROR);
	}
	
}